﻿CREATE TABLE [dbo].[Byggnad] (
    [Id]               UNIQUEIDENTIFIER NOT NULL,
    [ValId]            UNIQUEIDENTIFIER NOT NULL,
    [Skapad]           DATETIME         NOT NULL,
    [SkapadAv]         NVARCHAR (50)    NOT NULL,
    [Andrad]           DATETIME         NULL,
    [AndradAv]         NVARCHAR (50)    NULL,
    [Benamning]        NVARCHAR (255)   NOT NULL,
    [LeveransAdress]   NVARCHAR (255)   NULL,
    [LeveransPostNr]   NVARCHAR (255)   NULL,
    [LeveransPostOrt]  NVARCHAR (255)   NULL,
    [BesokAdress]      NVARCHAR (255)   NULL,
    [BesokPostNr]      NVARCHAR (255)   NULL,
    [BesokPostOrt]     NVARCHAR (255)   NULL,
    [StadsdelId]       UNIQUEIDENTIFIER NOT NULL,
    [TypId]            UNIQUEIDENTIFIER NOT NULL,
    [Inaktiv]          BIT              NOT NULL,
    [Koordinater]      NVARCHAR (255)   NULL,
    [KanExpandera]     BIT              NULL,
    [InformatorKravs]  BIT              NULL,
    [Fritext]          TEXT             NULL,
    [DocumentFolderId] UNIQUEIDENTIFIER NULL,
    [TelNr]            NVARCHAR (255)   NULL,
    [Hemsida]          NVARCHAR (255)   NULL,
    [Epost]            NVARCHAR (255)   NULL,
    CONSTRAINT [PK_Byggnad] PRIMARY KEY CLUSTERED ([Id] ASC, [ValId] ASC),
    CONSTRAINT [FK_Byggnad_ByggnadTyp1] FOREIGN KEY ([TypId], [ValId]) REFERENCES [dbo].[ByggnadTyp] ([Id], [ValId]),
    CONSTRAINT [FK_Byggnad_Stadsdel] FOREIGN KEY ([StadsdelId], [ValId]) REFERENCES [dbo].[Stadsdel] ([Id], [ValId])
);

















